#include <iostream>
#include <vector>
#include <queue>

using namespace std;
int N, A, B;
vector<int> a;
queue<int> q;
int b[2] = {1, -1};
int main() {
    cin >> N >> A >> B;
    if(A == B) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> flag(N + 1, 0);
    vector<int> p(N + 1, 0);
    for(int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    q.push(A);
    flag[A] = 1;
    while(!q.empty()) {
        int x = q.front();
        q.pop();
        for(int i = 0; i < 2; i++) {
            int y = x + b[i] * a[x - 1];
            if(y >= 1 && y <= N && flag[y] == 0) {
                q.push(y);
                flag[y] = 1;
                p[y] = p[x] + 1;
                if(y == B) {
                    cout << p[y] << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << endl;
    return 0;
}